<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>对账详情</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <div align="center">
            <span onclick="exportDetailFile();" id="exportDetailFile" class="sq-button sq-button-round" style="float: left">下载对账明细</span>
            <br/><br/>
            <span style="float: left"><strong>汇总信息</strong></span>
            <div id="mcrBillCheckGrid" class="sq-grid"></div>
            <br/><br/>
            <span style="float: left">差异记录</span>
            <div id="mcrBillCheckDiffGrid" class="sq-grid"></div>
        </div>
    </div>
</div>
<form id="mcrBillCheckDetail_form">
    <div class="fieldset1 clearFix">
        <div class="fieldBox blockBox clearFix">
            <div class="label">对账状态</div>
            <div class="field">
                <select name="diffStatus" id="diffStatus">
                    <option value="1" <c:if test="${mcrBillCheckVO.diffStatus =='1'}">selected</c:if>>平账</option>
                    <option value="2" <c:if test="${mcrBillCheckVO.diffStatus =='2'}">selected</c:if>>不平</option>
                </select>
            </div>
        </div>
        <div class="fieldBox blockBox clearFix">
            <span class="label">平账备注</span>
            <span class="field">
              <textarea id="remark"  name="remark" rows="3" class="l-textarea" style="width:360px; height: 68px;">
                  ${mcrBillCheckVO.remark}
              </textarea>
            </span>
        </div>
    </div>
</form>
<script type="text/javascript">
    var grid = null;
    var gridDiff = null;
    var importGrid;
    var _checkId = ${id};
    var resultList = ${resultList};
    $(function () {
        $("#mcrBillCheckDetail_form").ligerForm({
            validate: true
        });
        initGrid();
        initGridDiff();
    });
    //初始化汇总列表
    function initGrid(){
        $("#mcrBillCheckGrid").ligerGrid({
            columns: [
                { display: '资方', name: 'loanChannel', width: 100, enabledSort:true},
                { display: '对账类型', name: 'checkType', width: 100, enabledSort:true,
                    render: function (rowData) {
                        if (rowData.checkType == 1) {
                            return "放款";
                        } else if (rowData.checkType == 2) {
                            return "还款对账";
                        } else if (rowData.checkType == 3) {
                            return "回购对账";
                        } else if (rowData.checkType == 4) {
                            return "逾期对账";
                        } else {
                            return "未知";
                        }
                    }
                },
                { display: '对账日期', name: 'fileDate', width: 100, enabledSort:true },
                { display: '狮桥总金额(元)', name: 'shiqiaoAmt', width: 150, enabledSort:true,},
                { display: '资方总金额(元)', name: 'loanAmt', width: 150, enabledSort:true},
                { display: '狮桥总笔数', name: 'shiqiaoAmount', width: 100, enabledSort:true},
                { display: '资方总笔数', name: 'loanAmount', width: 100,enabledSort:true},
                { display: '对账状态', name: 'fileStatus', width: 100, enabledSort:true,
                    render:function(rowData){
                        if(rowData.fileStatus=="writing"){
                            return "正在拉取";
                        }else if (rowData.fileStatus=="unProcessed"){
                            return "对账未处理";
                        }else if (rowData.fileStatus=="processing"){
                            return "对账处理中";
                        }else if (rowData.fileStatus=="finished"){
                            return "对账已完成";
                        }
                    }
                }
            ],
            data: { Rows: resultList },
            width: '100%',
            usePager: false
        });
        grid = liger.get("mcrBillCheckGrid");
        grid.setHeight(130);
    }

    //初始化列表
    function initGridDiff(){
        $("#mcrBillCheckDiffGrid").ligerGrid({
            columns: [
                { display: '我方单边', name: 'myUnilateral'},
                { display: '资方单边', name: 'bankUnilateral'},
                { display: '不平记录', name: 'noBalance'}
            ],
            data: { Rows: resultList },
            width: '100%',
            usePager: false
        });
        gridDiff = liger.get("mcrBillCheckDiffGrid");
        gridDiff.setHeight(120);
    }
    function exportDetailFile() {
        var req = "checkId="+_checkId;
        window.location.href="<%=path%>/mcr/mcrBillCheck/exportDetailFile.do?"+req;
    }

    frameElement.dialog.onCancel = function () {
        frameElement.dialog.close();
    }

    //保存
    function save(){
        var ligerForm = liger.get("mcrBillCheckDetail_form");
        var data = ligerForm.getData();
        url = '<%=path%>/mcr/mcrBillCheck/modify.do';
        data["id"]= _checkId;
        AjaxUtils.ajaxPost(url, data, addCallback);
    }


    //新增回调
    function addCallback(msg){
        if(msg.success == 1){
            parent.grid.reload();
            UIUtils.alertSuccess("操作成功!");
            frameElement.dialog.close();
        }else{
            UIUtils.alertError(msg.info);
        }
    }
    //定义父级调用事件
    frameElement.dialog.onOk = function () {
        save();
    }

</script>
</body>
</html>